﻿using System.Collections.Generic;
using System.Data;
using System;
using FX.CC.Andon.Entity.Version;
using FX.CC.Andon.Utility.DataBase;

namespace FX.CC.Andon.Service.Version
{
    public class FileService : DbHelperBase
    {
        public IList<CEFile> GetFiles(Guid version)
        {
            IList<CEFile> list = new List<CEFile>();
            string sql = "Select * From UT_CEFile Where VersionID = @vid";
            using (var cmd = Db.GetSqlStringCommond(sql))
            {
                Db.AddInParameter(cmd, "@vid", DbType.Guid, version);
                try
                {
                    using (IDataReader reader = Db.ExecuteReader(cmd))
                    {
                        while (reader.Read())
                        {
                            var obj = new CEFile();
                            obj.VersionID =version;
                            obj.FileName = (string)reader[1];
                            obj.BIN = (byte[])reader[2];
                            list.Add(obj);
                        }
                    }
                }
                catch
                {
                    throw;
                }
            }
            return list;
        }
    }
}
